package com.zhang.cloud.controller;

import com.zhang.cloud.service.HystrixService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class PaymentController {

    @Resource
    private HystrixService hystrixService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/pay/hystrix/ok/{id}")
    public String paymentInfo_ok(@PathVariable("id")Integer id){
        String result = hystrixService.paymentInfo_ok(id);
        log.info("$$$$$  result: "+result);
        return result;
    }
    @GetMapping("/pay/hystrix/timeout/{id}")
    public String paymentInfo_timeout(@PathVariable("id")Integer id){
        String result = hystrixService.paymentInfo_TimeOut(id);
        log.info("$$$$$  result: "+result);
        return result;
    }


    //----服务熔断测试
    @GetMapping("/pay/hystrix/circuit/{id}")
    public String circuit(@PathVariable("id")Integer id)
    {
        String res = hystrixService.paymentCircuitBreaker(id);

        return res;
    }

}
